package Modelo.Controler;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import Model.Beans.Book;
import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

/**
 *
 * @author sixviv
 */
public class InstBooksMgmtAction extends ActionSupport{
    private Book book;
    private File fileUpload;
    private String uploadContentType; 
    private String uploadFileName;
    private String fileCaption;

    public String register() throws IOException{
        getBook().getPath();
        String fullFileName = "/images/";

        File theFile = new File(fullFileName);

        FileUtils.copyFile(fileUpload, theFile);
        return "success_get";
    }
    
    @Override
    public void validate(){
        if(book.getName().compareTo("") == 0){
            addFieldError("book.name", "El campo debe estar lleno");
        }
        else{
            
        }
    }

    /**
     * @return the book
     */
    public Book getBook() {
        return book;
    }

    /**
     * @param book the book to set
     */
    public void setBook(Book book) {
        this.book = book;
    }

    /**
     * @return the fileUpload
     */
    public File getFileUpload() {
        return fileUpload;
    }

    /**
     * @param fileUpload the fileUpload to set
     */
    public void setFileUpload(File fileUpload) {
        this.fileUpload = fileUpload;
    }

    /**
     * @return the uploadContentType
     */
    public String getUploadContentType() {
        return uploadContentType;
    }

    /**
     * @param uploadContentType the uploadContentType to set
     */
    public void setUploadContentType(String uploadContentType) {
        this.uploadContentType = uploadContentType;
    }

    /**
     * @return the uploadFileName
     */
    public String getUploadFileName() {
        return uploadFileName;
    }

    /**
     * @param uploadFileName the uploadFileName to set
     */
    public void setUploadFileName(String uploadFileName) {
        this.uploadFileName = uploadFileName;
    }

    /**
     * @return the fileCaption
     */
    public String getFileCaption() {
        return fileCaption;
    }

    /**
     * @param fileCaption the fileCaption to set
     */
    public void setFileCaption(String fileCaption) {
        this.fileCaption = fileCaption;
    }

}
